package com.PAT.UnSatisfying;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/11/30/20:43
 * @Description:
 * @Target: 差6分
 */
public class 互评成绩计算 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int count = 0;
        int sum = 0;
        int teacherScore = 0;
        ArrayList list = new ArrayList();

        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N ; j++) {
                int score = in.nextInt();
                if (j==1){
                    teacherScore = score;
                }else if (score>=0&&score<=M){
                    if (score>max){max=score;}
                    if (score<min){min=score;}
                    sum+=score;
                    count++;
                }
            }
            sum = (int)(((sum-max-min)/(count-2))+0.5);
            sum = (int)((sum+teacherScore+1)/2);
            list.add(sum);
            sum=0;
            count=0;
            max = Integer.MIN_VALUE;
            min = Integer.MAX_VALUE;
        }
       list.forEach(System.out::println);
    }
}
